<template>
  <a-modal
    title="窗口审核"
    :width="modalWidth"
    :visible="visible"
    :bodyStyle="bodyStyle"
    style="top: 0px;"
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭">

    <j-vxe-table
      ref="editableTable1"
      keep-source
      :height="300"
      :loading="table1.loading"
      :dataSource="table1.dataSource"
      :columns="table1.columns"
      @valueChange="handleValueChange"
      style="margin-top: 8px;"/>
  </a-modal>

</template>

<script>
  import splitPane from 'vue-splitpane'
  import SplitPanelA from './SplitPanelA'
  import SplitPanelB from './SplitPanelB'
  import { httpAction, getAction, postAction} from '@/api/manage'
  import { JVXETypes } from '@/components/jeecg/JVxeTable'

  export default {
    name: "WinModal",
    components:{
      splitPane,
      SplitPanelA,
      SplitPanelB
    },
    data () {
      return {
        title: '抗菌药物处方审核',
        Detail:{},
        visible: false,
        bodyStyle:{
          padding: "0",
          height:(window.innerHeight-300)+"px"
        },
        modalWidth:600,
        check:0,
        table1: {
          loading: false,
          dataSource: [],
          columns: [
            {
              title: '窗口号',
              key: 'id',
              width: '18%',
              type: JVXETypes.normal
            },
            {
              title: '人员',
              key: 'realName',
              width: '18%',
              type: JVXETypes.normal
            },
            {
              title: '是否上线',
              key: 'status',
              width: '24%',
              type: JVXETypes.checkbox,
              customValue: ['1','0'],
              placeholder: '请输入${title}'
            }
          ]
        },
        url: {
          add: '/rule/add',
          edit: '/window/online',
          list1: '/window/queryO',
        }
      }
    },
    created () {
      this.modalWidth = window.innerWidth-300;
    },
    methods: {
      show () {
        this.visible = true;
      },
      edit() {
        this.visible = true
        // this.model = Object.assign({}, record)
        let params = {}
        // 加载子表数据
        this.requestTableData(this.url.list1, params, this.table1)

      },
      handleValueChange(event) {
        console.log('handleValueChange.event: ', event)
        console.log('handleValueChange.event: ', event.row)

        postAction(this.url.edit, event.row).then(res => {

        }).finally(() => {

        })
      },
      handleOk(){

        this.visible = true;
      },
      detail(record) {
        this.model = Object.assign({}, record)
        this.Detail = this.model
        this.visible = true
        //this.getDetail();
      },
      handleCancel () {
        this.visible = false;
      },
      valueChange() {
        this.visible = false;
      },
      requestTableData(url, params, tab) {
        tab.loading = true
        getAction(url, params).then(res => {
          tab.dataSource = res.result.records || []
        }).finally(() => {
          tab.loading = false
        })
      },

    }
  }
</script>

<style scoped>
</style>